package com.hm.hsw1;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Demo {
    public static void main(String[] args) {
        List<String> one = new ArrayList<>();
        one.add("黄老邪");
        one.add("陈玄风");
        one.add("梅超风");
        one.add("陆乘风");
        one.add("曲灵风");
        one.add("武眠风");
        one.add("冯默风");
        one.add("罗玉风");
        List<String> two = new ArrayList<>();
        two.add("张三丰");
        two.add("宋远桥");
        two.add("俞莲舟");
        two.add("俞岱岩");
        two.add("张松溪");
        two.add("张翠山");
        two.add("殷梨亭");
        two.add("莫声谷");
        //1
        one.stream().filter(o->o.length()==3).forEach(System.out::println);
        //2
        System.out.println("====");
        one.stream().limit(3).forEach(System.out::println);
        //3
        two.stream().filter(o->o.startsWith("张")).forEach(System.out::println);
        //4
        System.out.println("=====");
        two.stream().skip(2).forEach(System.out::println);
        //5
        Stream.concat(one.stream(),two.stream()).forEach(o-> System.out.print(o+" "));
        List<String> collect = Stream.concat(one.stream(), two.stream()).collect(Collectors.toList());
        //6.
        ArrayList<Person> list = new ArrayList<>();
        System.out.println("====");
        collect.stream().forEach(o->list.add(new Person(o)));
        //7
        list.forEach(System.out::println);
        System.out.println("=============");
        Stream<String> limit = one.stream().filter(o -> o.length() == 3).limit(3);
        Stream<String> stream = two.stream().filter(o -> o.startsWith("张")).skip(2);
        Stream.concat(limit,stream).map(Person::new).forEach(System.out::println);
    }
}
